package jvm;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 堆溢出 -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError 当出现内存溢出时，自动下载dump文件
 * @Date 2022/11/17 10:53
 * @Created by wangjun
 */
public class HeapOOM {

    static class Person {
        private Integer id;
        private String name;
        private String address;

        public Integer getId() {
            return id;
        }

        public void setId(Integer id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public Person(Integer id, String name, String address) {
            this.id = id;
            this.name = name;
            this.address = address;
        }

        public Person() {
        }
    }

    public static void main(String[] args) {
        List<Person> list = new ArrayList<>();
        while (true) {
            list.add(new Person(1, "zhangsan", "beijing"));
        }
    }
}
